package com.shopping_center.management.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.shopping_center.management.mapper.PhoneMapper;
import com.shopping_center.management.model.Car;
import com.shopping_center.management.model.Phone;
import com.shopping_center.management.model.DropDownList;
import com.shopping_center.management.model.Phone;
import com.shopping_center.management.service.PhoneService;
import com.shopping_center.management.utils.GenerateUUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.sql.Timestamp;
import java.util.List;

@Service
public class PhoneServiceIpml implements PhoneService {

    @Autowired
    private PhoneMapper phoneMapper;

    @Override
    public void insertInToPhoneInfo(Phone phone) {
        Phone phoneInfo = new Phone();
        phoneInfo.setPhoneId(phone.getPhoneId());
        phoneInfo.setPhoneName(phone.getPhoneName());
        phoneInfo.setPhonePrice(phone.getPhonePrice());
        phoneInfo.setPhoneColour(phone.getPhoneColour());
        phoneInfo.setPhoneWeight(phone.getPhoneWeight());
        phoneInfo.setPhoneBy(phone.getPhoneBy());
        phoneMapper.insertInToPhoneInfo(phoneInfo);
    }

    @Override
    public void editPhoneInfo(Phone phone) {

    }

    @Override
    public void deletePhoneInfoById(String phoneId) {

    }

    @Override
    public PageInfo<Phone> selectAllPhoneInfo(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<Phone> phones = phoneMapper.selectAllPhoneInfo();
        if (!CollectionUtils.isEmpty(phones)) {
            PageInfo<Phone> pageInfo = new PageInfo<>(phones);
            return pageInfo;
        }
        return null;
    }

    @Override
    public List<Phone> selectAllPhoneInfoIntoExecl() {
        return null;
    }

}
